package com.treehouse.rpgdefender.component;

import com.artemis.Component;

/**
 * Component class for transformation entities.
 * 
 * @author Julian Biermann
 * @version 25.02.2013 21:09:15 v1.0
 * 
 */
public class Transformation extends Component {

	private float x;
	private float y;
	private float rotation;

	/**
	 * Sets the x and y coordinate and initialize the rotation with 0.0f.
	 * 
	 * @param x
	 *            The x coordinate.
	 * @param y
	 *            The y coordinate.
	 */
	public Transformation(float x, float y) {
		this.x = x;
		this.y = y;
		this.rotation = 0.0f;
	}

	/**
	 * Sets the x and y coordinate and also the rotation.
	 * 
	 * @param x
	 *            The x coordinate.
	 * @param y
	 *            The y coordinate.
	 * @param rotation
	 *            The rotation value.
	 */
	public Transformation(float x, float y, float rotation) {
		this(x, y);
		this.rotation = rotation;
	}

	/**
	 * @return x as float
	 */
	public float getX() {
		return x;
	}

	/**
	 * @param x
	 *            the x to set
	 */
	public void setX(float x) {
		this.x = x;
	}

	/**
	 * @return y as float
	 */
	public float getY() {
		return y;
	}

	/**
	 * @param y
	 *            the y to set
	 */
	public void setY(float y) {
		this.y = y;
	}

	/**
	 * @return rotation as float
	 */
	public float getRotation() {
		return rotation;
	}

	/**
	 * @param rotation
	 *            the rotation to set
	 */
	public void setRotation(float rotation) {
		this.rotation = rotation;
	}

	/**
	 * Adds a given value to the x coordinate.
	 * 
	 * @param amount
	 *            Value to be added.
	 */
	public void addX(float amount) {
		this.x += amount;
	}

	/**
	 * Adds a given value to the y coordinate.
	 * 
	 * @param amount
	 *            Value to be added.
	 */
	public void addY(float amount) {
		this.y += amount;
	}

	/**
	 * Adds a given value to the rotation.
	 * 
	 * @param amount
	 *            Value to be added.
	 */
	public void addToRotation(float amount) {
		this.rotation = (this.rotation + amount) % 360;
	}

	/**
	 * Sets the x and y coordinate.
	 * 
	 * @param x
	 *            New x coordinate.
	 * @param y
	 *            New y coordinate.
	 */
	public void setPosition(float x, float y) {
		this.x = x;
		this.y = y;
	}
}
